{include file="public/head" /}
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>后台管理</cite></a>
        <a><cite>物业管理系统</cite></a>
        <a><cite>物业信息</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
       <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="{url('billparklist')}">
          <input class="layui-input" placeholder="小区名称" name="community_name" id="community_name" {if isset($community_name)}value="{$community_name}"{/if}>
          
        
            <div class="layui-input-inline">
                <select name="gateid">
                  <option value="">位置类型</option>
                  {foreach $gatelist as $gateinfo}
                  <option value="{$gateinfo.id}" {if isset($gateid)}{if $gateid == $gateinfo.id}selected{/if}{/if}>{$gateinfo.gateName}</option>
                 {/foreach}
                </select>
            </div>
            
            
           <div class="layui-input-inline">
            <select name="invoice_type">
              <option value="">发票状态</option>
              <option value="1" {if isset($invoice_type)}{if $invoice_type == '1'}selected{/if}{/if}>已开票</option>
              <option value="3" {if isset($invoice_type)}{if $invoice_type == '3'}selected{/if}{/if}>未开票</option>
              <option value="2" {if isset($invoice_type)}{if $invoice_type == '2'}selected{/if}{/if}>已退票</option>
            </select>
          </div>
         
          <input class="layui-input" placeholder="开始时间" name="gmt_payment_start" id="start" {if isset($gmt_payment_start)}value="{$gmt_payment_start}"{/if}>
          <input class="layui-input" placeholder="结束时间" name="gmt_payment_end" id="end" {if isset($gmt_payment_end)}value="{$gmt_payment_end}"{/if}>
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
       <!--<button class="layui-btn" onclick="invoice()"><i class="layui-icon"></i>电子发票</button>-->
       <button class="layui-btn layui-btn-danger" onclick="billOrderExport('{$export}')"><i class="layui-icon"></i>批量导出</button>
        <span class="x-right" style="line-height:40px">支付宝收款:{$money.ali}元,微信收款:{$money.wx}元, &nbsp;&nbsp;&nbsp;&nbsp; 共有数据： {$number}  条</span>
      </xblock>
      <table class="layui-table" id="table">
        <thead  style="text-align:center;">
          <tr>
            <th style="text-align: center; font-size: 16px;">
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            
            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <th style="text-align: center; font-size: 16px;">岗亭</th>
            <th style="text-align: center; font-size: 16px;">金额</th>
            <th style="text-align: center; font-size: 16px;">支付方式</th>
            <th style="text-align: center; font-size: 16px;">付款时间</th>
            <th style="text-align: center; font-size: 16px;">发票状态</th>
            <th style="text-align: center; font-size: 16px;">操作</th>
          </tr>
        </thead>
        <tbody style="text-align:center;">
            {foreach $list as $lis}
            <tr>
              <td style="text-align: center;">
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$lis.id}'><i class="layui-icon">&#xe605;</i></div>
                </td>
              <td style="text-align: center;">{$lis.community_name}</td>
              <td style="text-align: center;">{$lis.gateName}</td>
              <td style="text-align: center;">{$lis.pay_money}</td>
              <td style="text-align: center;">
                  {if $lis.pay_type=="1"}
                    支付宝
                  {/if}
                  {if $lis.pay_type=="2"}
                    微信
                  {/if}
              </td>
              <td style="text-align: center;">{$lis.create_time}</td>
              <td style="text-align: center;">
                  {if $lis.invoice_type=="1"}
                    已开票
                  {/if}
                  {if $lis.invoice_type=="2"}
                    已退票
                  {/if}
                  {if $lis.invoice_type=="3"}
                    未开票
                  {/if}
              </td>
              <td class="td-manage" style="text-align: center;">
                {if $Think.session.usertype=="0"}
                {if $lis.order_status == "TRADE_SUCCESS"}
                <a title="退款"  onclick="x_admin_show('退款','{:url('orderrefund')}?id={$lis.id}',780,600)" href="javascript:;">
                  <i class="layui-icon"><img src="static/admin/images/refund.png" style="width:15px;height:15px"/</i>
                </a>
				{/if}
               {/if}
               
               {if $lis.invoice_type == 3 }
              <button class="layui-btn layui-btn-normal" onclick="x_admin_show('查看发票','{:url('invoice')}?id={$lis.id}',900,700)">开票</button>
             
              </a>
              {/if}
               
               {if $lis.invoice_type == 1 ||  $lis.invoice_type == 2}
              <button class="layui-btn" onclick="x_admin_show('查看发票','{:url('CheckEInvoice')}?id={$lis.id}',900,700)">查看</button>
             
              </a>
              {/if}
              {if $lis.invoice_type == 1}
              
                <button class="layui-btn layui-btn-danger" onclick="cancellation('{$lis.id}', '{$lis.id}')" id="red{$lis.id}">冲红</button>
             
              {/if}
              </td>
            </tr>
            {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div id="page">
            {$prolist->render()}
        </div>
      </div>

    </div>
    <script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
          ,format: 'yyyy-MM-dd HH:mm:ss'
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
          ,format: 'yyyy-MM-dd HH:mm:ss'
        });
      });
      function payurl(id){
        layer.open({
          type: 1,
          skin: 'x-right', //样式类名
          closeBtn: 0, //不显示关闭按钮
          anim: 2,
          shadeClose: true, //开启遮罩关闭
          area: ['80%', '300px'],
          content: 
          '<div style="padding: 20px 100px; font-size:18px">'+
         
          '缴费：http://www.wuye.zfbzhsq.com/admin/h5pay/gatepay?gateid='+ id + '<br><br>'+
         
          '</div>'
        });
      }
        
        
     function cancellation(id, doc){
        if(confirm('是否确定冲红?')) 
        { 

          var url = "{:url('Cancellation')}?id=" + id
          // console.log(url)
          window.location.href=url
          $('#red' + doc).attr('href', url)
        } 
          return false; 
      }
      
       function invoice(){
        if(confirm('是否确定开票?')){
          var datas = $('#table tbody td .layui-form-checked')
          var ids = []
          datas.each(function(index, element){
            var id = $(this).data('id')
            ids.push(id)
          })

          var str = ids.join(',');
          var count = ids.length
          var url = "{:url('invoice')}?id=" + str
          layer.open({
            type: 2,
            title: '批量开票',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '95%'],
            content: url //iframe的url
          }); 
        } 
      }
      
      //批量导出
      function billOrderExport(exportid){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        var url = "{:url('billOrderExport')}?id=" + str +'&export=' + exportid
        console.log(url);
        layer.open({
          type: 2,
          title: '批量导出',
          shadeClose: true,
          shade: 0.8,
          area: ['80%', '95%'],
          content: url //iframe的url
        }); 
      }
    </script>

    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

  </body>

</html>